Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: Fix window order breaking when closing modal dialog #10427

Merged
merged 4 commits into from
Feb 22, 2023

Conversation

grokys
Copy link
Member

@grokys grokys commented Feb 21, 2023

What does the pull request do?

Fixes the following scenario on macOS:

  • Open a child window of main window
  • Open a modal window as a child of main window
  • Close modal window
  • First child window should remain in front of main window, but it doesn't - it gets moved behind the main window.

This happens because sometimes (and always in this particular case), after windowDidBecomeKey is called and the window order is enforced via BringToFront, the window that became key is then moved to the front, breaking window order. Given that we're already invalidating the shadow by scheduling it on the dispatcher, use this opportunity to also enforce the window order again.

Adds an integration test to prevent regressions here.

For the following scenario:

- Open a child window of main window
- Open a modal window as a child of main window
- Close main window
- First child window should remain in front of main window
Sometimes, after `windowDidBecomeKey` is called and the window order is enforced via `BringToFront`, the window that became key is then moved to the front, breaking window order. Given that we're already invalidating the shadow by scheduling it on the dispatcher, use this opportunity to also enforce the window order again.
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0030372-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0030426-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0030432-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@danwalmsley danwalmsley merged commit 3596149 into master Feb 22, 2023
@danwalmsley danwalmsley deleted the fixes/macos-close-window-zorder branch February 22, 2023 22:26
grokys pushed a commit that referenced this pull request Feb 24, 2023
…rder

macOS: Fix window order breaking when closing modal dialog
donandren added a commit to donandren/Avalonia that referenced this pull request Mar 24, 2023
commit 45c009e
Author: Steven Kirk <[email protected]>
Date:   Thu Mar 23 15:21:13 2023 +0100

    Bump version

commit 02752e0
Author: Steven Kirk <[email protected]>
Date:   Thu Mar 23 12:13:35 2023 +0100

    Update ShowWindowTest from master.

    This branch had gone out-of-sync due to repeated cherry picks.

commit c9c1eb8
Author: Dan Walmsley <[email protected]>
Date:   Thu Mar 16 21:48:06 2023 +0000

    Merge pull request AvaloniaUI#10677 from AvaloniaUI/fixes/10650-extend-client-area-decorations

    macOS: Fix interaction between ExtendClientAreaToDecorationsHint and SystemDecorations

commit 9bebc76
Author: Dan Walmsley <[email protected]>
Date:   Tue Mar 7 22:24:50 2023 +0000

    Merge pull request AvaloniaUI#10575 from AvaloniaUI/fixes/macos-no-resize-zoom

    macOS: Don't allow window zoom when CanResize=false.

commit a674362
Author: Max Katz <[email protected]>
Date:   Wed Mar 8 15:52:19 2023 +0000

    Merge pull request AvaloniaUI#10600 from AvaloniaUI/fixes/x11window-nre

    Add nullable reference checking to X11Window.

commit afd25c8
Author: Steven Kirk <[email protected]>
Date:   Fri Feb 24 10:31:42 2023 +0100

    Set openssl-legacy-provider on all platforms.

    Linux is failing now with the same error.

commit 136a0ab
Author: Steven Kirk <[email protected]>
Date:   Wed Feb 22 14:34:34 2023 +0100

    Merge pull request AvaloniaUI#10431 from AvaloniaUI/fixes/osx-menu-reparenting-crash

    if the window is closed, we cannot become the key window.

commit 8096b59
Author: Dan Walmsley <[email protected]>
Date:   Wed Feb 22 22:26:24 2023 +0000

    Merge pull request AvaloniaUI#10427 from AvaloniaUI/fixes/macos-close-window-zorder

    macOS: Fix window order breaking when closing modal dialog

commit a5f20fb
Author: Steven Kirk <[email protected]>
Date:   Thu Feb 16 11:34:42 2023 +0100

    Only set openssl-legacy-provider on Windows.

commit cea9d20
Author: Steven Kirk <[email protected]>
Date:   Thu Feb 16 11:20:22 2023 +0100

    Try to fix CI build error.

    `error:0308010C:digital envelope routines::unsupported`

commit a082601
Author: Max Katz <[email protected]>
Date:   Sat Feb 4 08:22:00 2023 -0500

    Merge pull request AvaloniaUI#10204 from AvaloniaUI/update-angle-version

    Update Angle to 2.1.0.2023020321

commit 8d0f449
Author: Steven Kirk <[email protected]>
Date:   Tue Feb 14 20:04:44 2023 +0100

    Merge pull request AvaloniaUI#10265 from AvaloniaUI/fixes/macos-noresize-fullscreen

    Various macOS and win32 fixes

commit ac49092
Author: Max Katz <[email protected]>
Date:   Fri Feb 3 15:55:45 2023 -0500

    Merge pull request AvaloniaUI#10196 from AvaloniaUI/fixes/macos-transparency

    macOS: Fix window transparency

commit 730e08d
Author: Max Katz <[email protected]>
Date:   Tue Dec 13 12:56:33 2022 -0500

    Merge pull request AvaloniaUI#9699 from AvaloniaUI/fixes/7974-selectionmodel-eventargs-indexer

    Fix SelectionModelSelectionChangedEventArgs.SelectedItems indexer.

commit f3acb6e
Author: Steven Kirk <[email protected]>
Date:   Wed Feb 1 16:31:57 2023 +0100

    Merge pull request AvaloniaUI#10153 from AvaloniaUI/fixes/macos-windowstate-crash

    macOS: Sync actual window state after window show, and fix integration tests on macOS 13.1

commit 7d09e7c
Author: Max Katz <[email protected]>
Date:   Mon Jan 16 22:12:39 2023 -0500

    Merge pull request AvaloniaUI#9716 from AvaloniaUI/fixes/macos-child-window-key-handling

    macos: Fix child window key handling

commit fb67190
Author: Steven Kirk <[email protected]>
Date:   Thu Jan 12 15:47:56 2023 +0100

    Revert "Merge pull request AvaloniaUI#9947 from AvaloniaUI/stable/nswindow-setappearance"

    This reverts commit c273732, reversing
    changes made to d926650.

commit c273732
Merge: d926650 561b04a
Author: Dan Walmsley <[email protected]>
Date:   Tue Jan 10 12:40:08 2023 +0000

    Merge pull request AvaloniaUI#9947 from AvaloniaUI/stable/nswindow-setappearance

    [stable] macOS: Set Window appearance to fix missing white border

commit 561b04a
Author: Dan Walmsley <[email protected]>
Date:   Wed Dec 14 22:58:28 2022 +0000

    set appearance on osx window.

commit d926650
Author: Dan Walmsley <[email protected]>
Date:   Tue Dec 6 15:05:40 2022 +0000

    fix integration test app.

commit 96465de
Author: Dan Walmsley <[email protected]>
Date:   Tue Dec 6 15:01:04 2022 +0000

    Revert "remove integration test app."

    This reverts commit 46ea187.

commit 46ea187
Author: Dan Walmsley <[email protected]>
Date:   Tue Dec 6 14:38:36 2022 +0000

    remove integration test app.

commit f549f1e
Author: Dan Walmsley <[email protected]>
Date:   Tue Dec 6 14:26:09 2022 +0000

    fix build

commit 92687ad
Author: Max Katz <[email protected]>
Date:   Thu Sep 8 14:32:09 2022 +0200

    Merge pull request AvaloniaUI#8880 from AvaloniaUI/fixes/8878-mac-window-order

    macOS: Fix child window order with multiple child windows
    # Conflicts:
    #	tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

commit cb56351
Author: Max Katz <[email protected]>
Date:   Wed Nov 2 14:15:41 2022 -0400

    Merge pull request AvaloniaUI#9326 from AvaloniaUI/fixes/osx-child-windows-cant-minimise

    OSX: fix minimise button being disabled when either a parent or a dialog.

commit 0af2a96
Author: Max Katz <[email protected]>
Date:   Wed Nov 16 16:45:16 2022 -0800

    Merge pull request AvaloniaUI#9451 from AvaloniaUI/fixes/osx-native-menu-memory-leak

    [OSX] Fixed NativeMenu memory leak
    # Conflicts:
    #	src/Avalonia.MicroCom/CallbackBase.cs

commit fdb32b7
Author: Dan Walmsley <[email protected]>
Date:   Sat Nov 19 14:47:02 2022 +0000

    Merge pull request AvaloniaUI#9469 from AvaloniaUI/fixes/window-border-for-opaque-windows

    [OSX] Use non-opaque window background for non-transparent windows
    # Conflicts:
    #	src/Avalonia.Native/avn.idl

commit 1dacc90
Author: Max Katz <[email protected]>
Date:   Tue Dec 6 03:19:45 2022 -0800

    Merge pull request AvaloniaUI#9566 from AvaloniaUI/fixes/9565-mac-fullscreen-children

    MacOS: Only bring windows to front if they're on the active space.

commit d3723c6
Author: Max Katz <[email protected]>
Date:   Thu Jul 21 14:16:29 2022 -0400

    Merge pull request AvaloniaUI#8514 from pr8x/move-first-last-skip-disabled

    Skip disabled controls when moving to first/last item

commit 3e43d6f
Merge: 719d89f 8ee727f
Author: Dan Walmsley <[email protected]>
Date:   Wed Nov 30 13:46:37 2022 +0000

    Merge branch 'stable/0.10.x-outsys' into stable/0.10.x

commit 8ee727f
Author: Dan Walmsley <[email protected]>
Date:   Wed Nov 30 13:45:47 2022 +0000

    Revert "Fix AvaloniaUI#9565"

    This reverts commit 5fa4da3.

commit 8546725
Merge: ea71071 133abac
Author: Dan Walmsley <[email protected]>
Date:   Wed Nov 30 12:50:23 2022 +0000

    Merge pull request AvaloniaUI#9573 from AvaloniaUI/fixes/update-nuke

    Fix Stable Branch Builds

commit 133abac
Author: Dan Walmsley <[email protected]>
Date:   Wed Nov 30 12:35:09 2022 +0000

    fix create nuget packages.

commit ead8be7
Author: Dan Walmsley <[email protected]>
Date:   Wed Nov 30 11:00:53 2022 +0000

    use custom ilrepack.

commit 3432d2b
Author: Dan Walmsley <[email protected]>
Date:   Tue Nov 29 14:33:46 2022 +0000

    update nuke.

commit 6990327
Author: Dan Walmsley <[email protected]>
Date:   Tue Nov 29 14:26:20 2022 +0000

    update nukebuild.

commit ea71071
Author: Dan Walmsley <[email protected]>
Date:   Tue Nov 29 13:47:05 2022 +0000

    use 6.0.200

commit 16ce88c
Author: Steven Kirk <[email protected]>
Date:   Tue Nov 29 13:35:30 2022 +0100

    Pin SDK.

commit 5fa4da3
Author: Steven Kirk <[email protected]>
Date:   Tue Nov 29 12:40:02 2022 +0100

    Fix AvaloniaUI#9565

    - Only bring window to front if it's on the currently active space
    - Ensure correct order of child windows after fullscreen transition

commit 719d89f
Merge: ffe74ce 734e165
Author: Max Katz <[email protected]>
Date:   Fri Nov 25 15:45:58 2022 -0500

    Merge pull request AvaloniaUI#9538 from timunie/backport/GH_9528

    Backport AvaloniaUI#9528

commit 734e165
Author: Tim <[email protected]>
Date:   Fri Nov 25 10:53:23 2022 +0100

    Backport AvaloniaUI#9528

commit ffe74ce
Author: Max Katz <[email protected]>
Date:   Thu Nov 17 19:54:14 2022 -0500

    Merge pull request AvaloniaUI#9221 from AvaloniaUI/fixes/8869-show-windowstate

    Fix setting WindowState before showing Window.

commit a64fcdd
Merge: a35520c 80288aa
Author: Max Katz <[email protected]>
Date:   Sun Oct 30 00:01:09 2022 -0400

    Merge pull request AvaloniaUI#9300 from AvaloniaUI/fixes/osx-menu-reentrancy-crash

    OSX: fix menu re-entrancy crash

commit 80288aa
Author: Dan Walmsley <[email protected]>
Date:   Fri Oct 28 11:48:27 2022 +0100

    use didResignKey notification instead of override resignKey

commit a35520c
Author: Dan Walmsley <[email protected]>
Date:   Thu Oct 27 15:03:55 2022 +0100

    Revert "Merge branch 'disableSetProcessName-feature' into tmp8"

    This reverts commit d8ee76d.

commit d8ee76d
Author: Dan Walmsley <[email protected]>
Date:   Mon Oct 3 17:03:56 2022 +0100

    Merge branch 'disableSetProcessName-feature' into tmp8

commit 62a5ee1
Author: Max Katz <[email protected]>
Date:   Sat Aug 13 03:34:22 2022 -0400

    Merge pull request AvaloniaUI#8739 from AvaloniaUI/update-skia

    Update SkiaSharp
    # Conflicts:
    #	build/HarfBuzzSharp.props

commit 0ac982f
Merge: 9f50abd 96187d7
Author: Dan Walmsley <[email protected]>
Date:   Mon Aug 15 13:39:20 2022 +0100

    Merge pull request AvaloniaUI#8753 from AvaloniaUI/fix-listBoxTests-stable

    Fix ListBoxTests on stable

commit 96187d7
Author: Takoooooo <[email protected]>
Date:   Mon Aug 15 15:20:34 2022 +0300

    Fix ListBoxTests.

commit 9f50abd
Author: Dan Walmsley <[email protected]>
Date:   Mon Mar 7 16:54:24 2022 +0000

    Merge pull request AvaloniaUI#7755 from AvaloniaUI/fixes/win32-can-resize

    Fixes/win32 can resize

commit ff86693
Author: Max Katz <[email protected]>
Date:   Thu Aug 11 19:30:58 2022 -0400

    Merge pull request AvaloniaUI#8728 from jp2masa/gl-control-render-rect

    Fixed OpenGlControlBase render rect

commit 7627db1
Author: Max Katz <[email protected]>
Date:   Sat Aug 6 05:28:31 2022 -0400

    Merge pull request AvaloniaUI#8683 from AvaloniaUI/stop-transition-if-it-was-cancelled

    Stop TransitioningContentControl if it was cancelled

commit 7eb0a48
Author: Max Katz <[email protected]>
Date:   Sun Aug 7 02:52:50 2022 -0400

    Merge pull request AvaloniaUI#8569 from hez2010/visual-fixes

    Avoid crashing when fail to create OpenGL context

commit 5f9c852
Author: Dan Walmsley <[email protected]>
Date:   Tue Aug 9 18:38:40 2022 +0100

    Merge pull request AvaloniaUI#8574 from AvaloniaUI/fixes/win32-consistent-minimize-restore-window-size

    Win32: Retain window position and size when docked and then minimized and restored.
    # Conflicts:
    #	tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

commit 46d83d1
Author: Dan Walmsley <[email protected]>
Date:   Tue Aug 9 17:09:06 2022 +0100

    Merge pull request AvaloniaUI#8618 from AvaloniaUI/fixes/macos-dont-reopen-hidden-window

    macos: Don't reopen hidden window when parent clicked.
    # Conflicts:
    #	tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

commit d758481
Merge: 765c4d7 7b33526
Author: Max Katz <[email protected]>
Date:   Tue Aug 9 01:29:08 2022 -0400

    Merge pull request AvaloniaUI#8699 from timunie/fix/backport_GH_7778

    Backport PR 7778

commit 7b33526
Author: Tim <[email protected]>
Date:   Mon Aug 8 11:24:12 2022 +0200

    Backport PR 7778

commit 765c4d7
Author: Tako <[email protected]>
Date:   Wed Aug 3 18:44:47 2022 +0300

    Merge pull request AvaloniaUI#8655 from AvaloniaUI/use-correct-toggleModifier-for-treeView-on-macOS-with-multiselection

    Use correct ToggleModifier in TreeView multiselection on MacOS

commit fb607cc
Author: Steven Kirk <[email protected]>
Date:   Wed Aug 3 17:05:21 2022 +0200

    Merge pull request AvaloniaUI#8637 from AvaloniaUI/use-correct-toggleModifier-for-listBox-on-macOS-with-multiselection

    Use correct ToggleModifier in ListBox multiselection on MacOS.

commit fcada17
Author: Steven Kirk <[email protected]>
Date:   Wed Aug 3 18:24:46 2022 +0200

    Added AvaloniaLocator.GetRequiredService.

commit 50f02de
Author: Max Katz <[email protected]>
Date:   Tue Jul 26 23:06:08 2022 -0400

    Merge pull request AvaloniaUI#8604 from AvaloniaUI/feature/tray-icon-non-mandatory

    Don't throw exceptions for missing windowing platform since it's actually not mandatory for TrayIcon

commit dfabf4d
Author: Max Katz <[email protected]>
Date:   Sat Jul 30 13:56:36 2022 -0400

    Merge pull request AvaloniaUI#8599 from jinek/fixes/scene-hittest-exclusive

    Scene hittest now uses exclusive `Rect.Contains`. Fixes https://githu…

commit 1628b20
Author: Nikita Tsukanov <[email protected]>
Date:   Tue Jul 26 13:52:23 2022 +0300

    Merge pull request AvaloniaUI#8597 from AvaloniaUI/feature/x11-wmclass-spec

    Set WM_CLASS property according to ICCCM spec

commit d2f8fe6
Author: Jumar Macato <[email protected]>
Date:   Fri Jul 15 21:04:07 2022 +0800

    Merge pull request AvaloniaUI#8520 from timunie/fix/DataGrid_LastColumnIsClipped

    fix: RowDesiredWidth was missing the RowHeaderWidth

commit 2d2cd97
Author: Max Katz <[email protected]>
Date:   Thu Jul 28 12:04:17 2022 -0400

    Backport proper exception handling in win32 system dialogs

commit 7fb8c01
Author: Nikita Tsukanov <[email protected]>
Date:   Tue Jul 26 16:41:15 2022 +0300

    Merge pull request AvaloniaUI#8601 from AvaloniaUI/fixes/7773-skia-stream-workaround

    Workaround for SkiaSharp broken image decoding.

commit e975100
Author: Dan Walmsley <[email protected]>
Date:   Mon Jul 18 15:38:27 2022 +0100

    Merge pull request AvaloniaUI#8538 from AvaloniaUI/feature/expose-gtk-thread-invoke

    Introduced GtkInteropHelper.RunOnGlibThread, fixed demos
    # Conflicts:
    #	samples/ControlCatalog.NetCore/NativeControls/Gtk/EmbedSample.Gtk.cs
    #	samples/ControlCatalog.NetCore/NativeControls/Gtk/GtkHelper.cs

# Conflicts:
#	build/SharedVersion.props
#	nukebuild/Build.cs
#	samples/IntegrationTestApp/ShowWindowTest.axaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants